#include<iostream>
#include<deque>

using namespace std;

const int N=2e5+10;

int n,a[N];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int mmax=-1;
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]);
		
		if(a[1] != n && a[n] != n)
		{
			puts("-1");
			continue;
		}
		
		deque<int> q;
		int l=1,r=n;
		int flag=1;
		while(l<=r)
		{
			if(flag&1) 
			{
				q.push_back(a[r]);
				r--;
			}
			else
			{
				q.push_front(a[l]);
				l++;
			}
			flag++;
		}
		for(deque<int>::iterator it=q.begin();it!=q.end();it++)
		{
			printf("%d ",*it);
		}
		puts("");
	}
	return 0;
}
